use std::sync::Arc;
use tokio::sync::Mutex;
use tokio::task;

#[tokio::main]
async fn main() {
    let db = vec![1,2,3];
    let db_ac = Arc::new(Mutex::new(db));
    let db1 = db_ac.clone();
    let db2 = db_ac.clone();

    let task_a = task::spawn(async move {
        let mut db = db1.lock().await;
        db[1] = 50;
    });

    let task_b = task::spawn(async move {
        let mut db = db2.lock().await;
        db[1] = 100;
    });

    task_a.await.expect("err");
    task_b.await.expect("err");

    let db3 = db_ac.clone();
    println!("{:?}", db3.lock().await);

}